var parentId = getUrlParam('parentId');

var app = angular.module('cancer', []);
app.controller('group', function($scope, $http) {
  $scope.getUrl = getUrlParam('getUrl');
  $scope.createUrl = getUrlParam('createUrl');
  $scope.saveUrl = getUrlParam('saveUrl');
  $scope.action = $scope.createUrl;
  $scope.group = {parentId: parentId};

  $scope.getGroup = function() {
    if($scope.getUrl!=null) {
      $http({
        method: 'POST',
        url: $scope.getUrl,
      }).then(function successCallback(response) {
        $scope.group = response.data;
        $scope.action = $scope.saveUrl;
      }, function errorCallback(response) {
        // 请求失败执行代码
      });
    }
  }

  $scope.setGroup = function() {
    $http({
      method: 'POST',
      url: $scope.action,
      data: $scope.group
    }).then(function successCallback(response) {
      callback('okback');
    }, function errorCallback(response) {
      // 请求失败执行代码
    });
  }

  $scope.getGroup();
});

function cancel()
{
  callback('cancelback');
}

function callback(call)
{
  var frame = getMainElement('frm_mainCard')[0].contentWindow;
  var script = 'frame.' + getUrlParam(call)+'()';
  eval(script);
}
